<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/7/15 0015
 * Time: 17:12
 */

namespace app\api\controller\v1;


use library\Controller;
use think\Db;

class Article extends Controller
{
    protected $table = 'Article';

    /**
     * 文章列表
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function index()
    {
        $list = $this->_query($this->table)->where('status','eq','1')->like('title')->order('create_at desc')->page(true,false,false,10);
        $this->success('success',$list);
    }

    /**
     * 获取详情
     * @param $id
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function read($id)
    {
        $where = [['id','eq',$id],['status','eq','1']];
        $this->success('success',Db::name($this->table)->where($where)->find());
    }
}